diff --git a/src/www/ui/admin-config.php b/src/www/ui/admin-config.php
index af74f08a..df6125a4 100644
--- a/src/www/ui/admin-config.php
+++ b/src/www/ui/admin-config.php
@@ -1,165 +1,165 @@
Name = "foconfig";
$this->Title = TITLE_foconfig;
$this->MenuList = "Admin::Customize";
$this->DBaccess = PLUGIN_DB_ADMIN;
$this->PluginLevel = 50; // run before 'regular' plugins
parent::__construct();
$this->dbManager = $GLOBALS['container']->get('db.manager');
}
/**
* \brief Generate HTML output.
*/
function HTMLout()
{
global $PG_CONN;
$OutBuf="";
/* get config rows from sysconfig table */
$sql = "select * from sysconfig order by group_name, group_order";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
$Group = "";
$InputStyle = "style='background-color:#dbf0f7'";
$OutBuf .= "
$UpdateMsg
";
$OutBuf .= $this->HTMLout();
}
$this->vars['content'] = $OutBuf;
}
}
$NewPlugin = new foconfig;
$NewPlugin->Initialize();
diff --git a/src/www/ui/admin-dashboard.php b/src/www/ui/admin-dashboard.php
index 3f85dd41..367257c3 100644
--- a/src/www/ui/admin-dashboard.php
+++ b/src/www/ui/admin-dashboard.php
@@ -1,369 +1,351 @@
Name = "dashboard";
$this->Title = TITLE_dashboard;
$this->MenuList = "Admin::Dashboard";
$this->DBaccess = PLUGIN_DB_ADMIN;
parent::__construct();
+ $this->dbManager = $GLOBALS['container']->get('db.manager');
}
/**
* \brief Return each html row for DatabaseContents()
* \returns html table row
*/
function DatabaseContentsRow($TableName, $TableLabel)
{
- global $PG_CONN;
-
- // $sql = "SELECT count(*) AS val FROM $TableName;"; too slow on big tables, use pg_class which will be accurate as of last ANALYZE
- //$sql = "select reltuples as val from pg_class where relname='$TableName'"; this doesn't handle uploadtree
- $sql = "select sum(reltuples) as val from pg_class where relname like '$TableName' and reltype !=0";
- $result = pg_query($PG_CONN, $sql);
- DBCheckResult($result, $sql, __FILE__, __LINE__);
- $row = pg_fetch_assoc($result);
+ $row = $this->dbManager->getSingleRow(
+ "select sum(reltuples) as val from pg_class where relname like $1 and reltype !=0",
+ array($TableName),
+ __METHOD__);
$item_count = $row['val'];
- pg_free_result($result);
$V = "$TableLabel | ";
$V .= "" . number_format($item_count,0,"",",") . " | ";
$LastVacTime = $this->GetLastVacTime($TableName);
if (empty($LastVacTime))
$mystyle = "style=background-color:red";
else
$mystyle = "";
$V .= "" . substr($LastVacTime, 0, 16) . " | ";
$LastAnalyzeTime = $this->GetLastAnalyzeTime($TableName);
if (empty($LastAnalyzeTime))
$mystyle = "style=background-color:red";
else
$mystyle = "";
$V .= "" . substr($LastAnalyzeTime, 0, 16) . " | ";
$V .= "
\n";
return $V;
}
/**
* \brief Database Contents metrics
* \returns html table containing metrics
*/
function DatabaseContents()
{
$V = "\n";
$head1 = _("Metric");
$head2 = _("Total");
$head3 = _("Last
Vacuum");
$head4 = _("Last
Analyze");
$V .= "$head1 | $head2 | $head3 | $head4 |
\n";
/**** Users ****/
$V .= $this->DatabaseContentsRow("users", _("Users"));
/**** Uploads ****/
$V .= $this->DatabaseContentsRow("upload", _("Uploads"));
/**** Unique pfiles ****/
$V .= $this->DatabaseContentsRow("pfile", _("Unique files referenced in repository"));
/**** uploadtree recs ****/
$V .= $this->DatabaseContentsRow("uploadtree_%", _("Individual Files"));
/**** License recs ****/
$V .= $this->DatabaseContentsRow("license_file", _("Discovered Licenses"));
/**** Copyright recs ****/
$V .= $this->DatabaseContentsRow("copyright", _("Copyrights/URLs/Emails"));
$V .= "
\n";
return $V;
}
-function GetLastVacTime($TableName)
+function GetLastAnalyzeTimeOrVacTime($queryPart,$TableName)
{
- global $PG_CONN;
-
- $sql = "select greatest(last_vacuum, last_autovacuum) as lasttime from pg_stat_all_tables where schemaname = 'public' and relname like '$TableName'";
- $result = pg_query($PG_CONN, $sql);
- DBCheckResult($result, $sql, __FILE__, __LINE__);
- $row = pg_fetch_assoc($result);
- pg_free_result($result);
+ $sql = "select greatest($queryPart) as lasttime from pg_stat_all_tables where schemaname = 'public' and relname like $1";
+ $row = $this->dbManager->getSingleRow($sql, array($TableName), __METHOD__);
return $row["lasttime"];
}
-function GetLastAnalyzeTime($TableName)
+
+function GetLastVacTime($TableName)
{
- global $PG_CONN;
+ return GetLastAnalyzeTimeOrVacTime("last_vacuum, last_autovacuum",$TableName);
+}
- $sql = "select greatest(last_analyze, last_autoanalyze) as lasttime from pg_stat_all_tables where schemaname = 'public' and relname like '$TableName'";
- $result = pg_query($PG_CONN, $sql);
- DBCheckResult($result, $sql, __FILE__, __LINE__);
- $row = pg_fetch_assoc($result);
- pg_free_result($result);
-
- return $row["lasttime"];
+function GetLastAnalyzeTime($TableName)
+{
+ return GetLastAnalyzeTimeOrVacTime("last_analyze, last_autoanalyze",$TableName);
}
/**
* \brief Database metrics
* \returns html table containing metrics
*/
function DatabaseMetrics()
{
- global $PG_CONN;
$V = "\n";
$text = _("Metric");
$text1 = _("Total");
$V .= "$text | $text1 |
\n";
/* Database size */
$sql = "SELECT pg_database_size('fossology') as val;";
- $result = pg_query($PG_CONN, $sql);
- DBCheckResult($result, $sql, __FILE__, __LINE__);
- $row = pg_fetch_assoc($result);
+ $row = $this->dbManager->getSingleRow($sql, array(), __METHOD__."get_Size");
$Size = HumanSize($row['val']);
- pg_free_result($result);
$text = _("FOSSology database size");
$V .= "$text | ";
$V .= " $Size |
\n";
/**** Version ****/
$text = _("Postgresql version");
$V .= "$text | ";
$V .= " {$this->pgVersion[server]} |
\n";
/**** Query stats ****/
// count current queries
$sql = "SELECT count(*) AS val FROM pg_stat_activity";
- $result = pg_query($PG_CONN, $sql);
- DBCheckResult($result, $sql, __FILE__, __LINE__);
- $row = pg_fetch_assoc($result);
+ $row = $this->dbManager->getSingleRow($sql, array(), __METHOD__."get_connection_count");
$connection_count = $row['val'];
- pg_free_result($result);
/**** Active connection count ****/
$current_query = (strcmp($this->pgVersion['server'], "9.2") >= 0) ? "state" : "current_query";
$text = _("Active database connections");
$V .= "$text | ";
$V .= "" . number_format($connection_count,0,"",",") . " |
\n";
- $sql = "SELECT count(*) AS val FROM pg_stat_activity WHERE $current_query != '' AND datname = 'fossology'";
- $result = pg_query($PG_CONN, $sql);
- DBCheckResult($result, $sql, __FILE__, __LINE__);
- pg_free_result($result);
$V .= "
\n";
return $V;
}
/**
* \brief Database queries
* \returns html table containing query strings, pid, and start time
*/
function DatabaseQueries()
{
- global $PG_CONN;
-
$V = "\n";
$head1 = _("PID");
$head2 = _("Query");
$head3 = _("Started");
$head4 = _("Elapsed");
$V .= "$head1 | $head2 | $head3 | $head4 |
\n";
- // Get the current query column name in pg_stat_activity
$current_query = (strcmp($this->pgVersion['server'], "9.2") >= 0) ? "state" : "current_query";
$procpid = (strcmp($this->pgVersion['server'], "9.2") >= 0) ? "pid" : "procpid";
-
$sql = "SELECT $procpid processid, $current_query, query_start, now()-query_start AS elapsed FROM pg_stat_activity WHERE $current_query != '' AND datname = 'fossology' ORDER BY $procpid";
- $result = pg_query($PG_CONN, $sql);
- DBCheckResult($result, $sql, __FILE__, __LINE__);
+
+ $statementName = __METHOD__."queryFor_".$current_query."_orderBy_".$procpid;
+ $this->dbManager->prepare($statementName,$sql);
+ $result = $this->dbManager->execute($statementName, array());
+
if (pg_num_rows($result) > 1)
{
while ($row = pg_fetch_assoc($result))
{
if ($row[$current_query] == $sql) continue; // Don't display this query
$V .= "";
$V .= "$row[processid] | ";
$V .= "" . htmlspecialchars($row[$current_query]) . " | ";
$StartTime = substr($row['query_start'], 0, 19);
$V .= "$StartTime | ";
$V .= "$row[elapsed] | ";
$V .= "
\n";
}
}
else
$V .= "There are no active FOSSology queries |
";
pg_free_result($result);
$V .= "
\n";
return $V;
}
/**
* \brief Determine amount of free disk space.
*/
function DiskFree()
{
global $SYSCONFDIR;
global $SysConf;
$Cmd = "df -hP";
$Buf = $this->DoCmd($Cmd);
/* Separate lines */
$Lines = explode("\n",$Buf);
/* Display results */
$V = "";
$V .= "\n";
$head0 = _("Filesystem");
$head1 = _("Capacity");
$head2 = _("Used");
$head3 = _("Available");
$head4 = _("Percent Full");
$head5 = _("Mount Point");
$V .= "$head0 | $head1 | $head2 | $head3 | $head4 | $head5 |
\n";
$headerline = true;
foreach($Lines as $L)
{
// Skip top header line
if ($headerline)
{
$headerline = false;
continue;
}
if (empty($L)) { continue; }
$L = trim($L);
$L = preg_replace("/[[:space:]][[:space:]]*/"," ",$L);
$List = explode(" ",$L);
// Skip some filesystems we are not interested in
if ($List[0] == 'tmpfs') continue;
if ($List[0] == 'udev') continue;
if ($List[0] == 'none') continue;
if ($List[5] == '/boot') continue;
$V .= "" . htmlentities($List[0]) . " | ";
$V .= "$List[1] | ";
$V .= "$List[2] | ";
$V .= "$List[3] | ";
// Warn if running out of disk space
$PctFull = (int)$List[4];
$WarnAtPct = 90; // warn the user if they exceed this % full
if ($PctFull > $WarnAtPct)
$mystyle = "style=border-right:none;background-color:red";
else
$mystyle = "style='border-right:none'";
$V .= "$List[4] | ";
$V .= "" . htmlentities($List[5]) . " |
\n";
}
$V .= "
\n";
/*** Print out important file paths so users can interpret the above "df" ***/
$V .= _("Note:") . "
";
$Indent = " ";
// File path to the database
$V .= $Indent . _("Database"). ": " . " ";
// Get the database data_directory. If we were the superuser we could
// just query the database with "show data_directory", but we are not.
// So try to get it from a ps and parse the -D argument
$Cmd = "ps -eo cmd | grep postgres | grep -- -D";
$Buf = $this->DoCmd($Cmd);
// Find the -D
$DargToEndOfStr = trim(substr($Buf, strpos($Buf, "-D") + 2 ));
$DargArray = explode(' ', $DargToEndOfStr);
$V .= $DargArray[0] . "
";
// Repository path
$V .= $Indent . _("Repository") . ": " . $SysConf['FOSSOLOGY']['path'] . "
";
// FOSSology config location
$V .= $Indent . _("FOSSology config") . ": " . $SYSCONFDIR . "
";
return($V);
}
public function Output() {
global $PG_CONN;
$this->pgVersion = pg_version($PG_CONN);
$V="";
$V .= "\n";
$V .= "\n";
$text = _("Database Contents");
$V .= "$text\n";
$V .= $this->DatabaseContents();
$V .= " | ";
$V .= "\n";
$text = _("Database Metrics");
$V .= "$text\n";
$V .= $this->DatabaseMetrics();
$V .= " | ";
$V .= "
\n";
$text = _("Active FOSSology queries");
$V .= "$text
\n";
$V .= $this->DatabaseQueries();
$text = _("Disk Space");
$V .= "$text
\n";
$V .= $this->DiskFree();
return $V;
}
/**
* \brief execute a shell command
* \param $cmd - command to execute
* \return command results
*/
protected function DoCmd($cmd)
{
$fin = popen($cmd,"r");
$buffer = "";
while (!feof($fin)) {
$buffer .= fread($fin, 8192);
}
pclose($fin);
return $buffer;
}
}
$NewPlugin = new dashboard;
$NewPlugin->Initialize();
diff --git a/src/www/ui/admin-folder-delete.php b/src/www/ui/admin-folder-delete.php
index 5a8e9e97..ac527a5c 100644
--- a/src/www/ui/admin-folder-delete.php
+++ b/src/www/ui/admin-folder-delete.php
@@ -1,131 +1,131 @@
Name = "admin_folder_delete";
$this->Title = TITLE_admin_folder_delete;
$this->MenuList = "Organize::Folders::Delete Folder";
$this->Dependency = array();
$this->DBaccess = PLUGIN_DB_WRITE;
parent::__construct();
$this->dbManager = $GLOBALS['container']->get('db.manager');
}
/**
* \brief Delete
* Creates a job to detele the folder
*
* \param $folderpk - the folder_pk to remove
* \return NULL on success, string on failure.
*/
function Delete($folderpk, $Depends = NULL)
{
/* Can't remove top folder */
if ($folderpk == FolderGetTop()) {
$text = _("Can Not Delete Root Folder");
return ($text);
}
/* Get the folder's name */
$FolderName = FolderGetName($folderpk);
/* Prepare the job: job "Delete" */
$userId = Auth::getUserId();
$groupId = Auth::getGroupId();
$jobpk = JobAddJob($userId, $groupId, "Delete Folder: $FolderName");
if (empty($jobpk) || ($jobpk < 0)) {
$text = _("Failed to create job record");
return ($text);
}
/* Add job: job "Delete" has jobqueue item "delagent" */
$jqargs = "DELETE FOLDER $folderpk";
$jobqueuepk = JobQueueAdd($jobpk, "delagent", $jqargs, NULL, NULL);
if (empty($jobqueuepk)) {
$text = _("Failed to place delete in job queue");
return ($text);
}
/* Tell the scheduler to check the queue. */
$success = fo_communicate_with_scheduler("database", $output, $error_msg);
if (!$success) return $error_msg . "\n" . $output;
return (NULL);
} // Delete()
/**
* \brief Generate the text for this plugin.
*/
public function Output() {
/* If this is a POST, then process the request. */
$folder = GetParm('folder', PARM_INTEGER);
if (!empty($folder)) {
$rc = $this->Delete($folder);
$sql = "SELECT * FROM folder where folder_pk = $1;";
- $Folder = $this->dbManager->getSingleRow($sql,array($folder),__METHOD__.md5($sql));
+ $Folder = $this->dbManager->getSingleRow($sql,array($folder),__METHOD__."GetRowWithFolderName");
if (empty($rc)) {
/* Need to refresh the screen */
$text = _("Deletion of folder ");
$text1 = _(" added to job queue");
$this->vars['message'] = $text . $Folder['folder_name'] . $text1;
}
else {
$text = _("Deletion of ");
$text1 = _(" failed: ");
$this->vars['message'] = $text . $Folder['folder_name'] . $text1 . $rc;
}
}
$V= "\n";
return $V;
}
}
$NewPlugin = new admin_folder_delete;
diff --git a/src/www/ui/admin-folder-edit.php b/src/www/ui/admin-folder-edit.php
index eed28505..ee667e8f 100644
--- a/src/www/ui/admin-folder-edit.php
+++ b/src/www/ui/admin-folder-edit.php
@@ -1,105 +1,105 @@
Name = "folder_properties";
$this->Title = TITLE_folder_properties;
$this->MenuList = "Organize::Folders::Edit Properties";
$this->Dependency = array();
$this->DBaccess = PLUGIN_DB_WRITE;
parent::__construct();
$this->dbManager = $GLOBALS['container']->get('db.manager');
}
/**
* \brief Given a folder's ID and a name, alter
* the folder properties.
* Includes idiot checking since the input comes from stdin.
* \return 1 if changed, 0 if failed.
*/
function Edit($FolderId, $NewName, $NewDesc) {
$sql = 'SELECT * FROM folder where folder_pk = $1;';
- $Row = $this->dbManager->getSingleRow($sql,array($FolderId),__METHOD__.md5($sql));
+ $Row = $this->dbManager->getSingleRow($sql,array($FolderId),__METHOD__."Get");
/* If the folder does not exist. */
if ($Row['folder_pk'] != $FolderId) {
return (0);
}
$NewName = trim($NewName);
if (!empty($FolderId)) {
// Reuse the old name if no new name was given
if (empty($NewName)) {
$NewName = $Row['folder_name'];
}
// Reuse the old description if no new description was given
if (empty($NewDesc)) {
$NewDesc = $Row['folder_desc'];
}
}
else {
return (0); // $FolderId is empty
}
/* Change the properties */
$sql = 'UPDATE folder SET folder_name = $1, folder_desc = $2 WHERE folder_pk = $3;';
- $this->dbManager->getSingleRow($sql,array($NewName, $NewDesc, $FolderId),__METHOD__.md5($sql));
+ $this->dbManager->getSingleRow($sql,array($NewName, $NewDesc, $FolderId),__METHOD__."Set");
return (1);
}
/**
* \brief Generate the text for this plugin.
*/
public function Output() {
/* If this is a POST, then process the request. */
$FolderSelectId = GetParm('selectfolderid', PARM_INTEGER);
if (empty($FolderSelectId)) {
$FolderSelectId = FolderGetTop();
}
$FolderId = GetParm('oldfolderid', PARM_INTEGER);
$NewName = GetParm('newname', PARM_TEXT);
$NewDesc = GetParm('newdesc', PARM_TEXT);
if (!empty($FolderId)) {
$FolderSelectId = $FolderId;
$rc = $this->Edit($FolderId, $NewName, $NewDesc);
if ($rc == 1) {
/* Need to refresh the screen */
$text=_("Folder Properties changed");
$this->vars["message"] = $text;
}
}
/* Get the folder info */
$sql = 'SELECT * FROM folder WHERE folder_pk = $1;';
- $Folder = $this->dbManager->getSingleRow($sql,array($FolderSelectId),__METHOD__.md5($sql));
+ $Folder = $this->dbManager->getSingleRow($sql,array($FolderSelectId),__METHOD__."getFolderRow");
/* Display the form */
$formVars["onchangeURI"] = Traceback_uri() . "?mod=" . $this->Name . "&selectfolderid=";
$formVars["folderListOption"] = FolderListOption(-1, 0, 1, $FolderSelectId);
$formVars["folder_name"] = $Folder['folder_name'];
$formVars["folder_desc"] = $Folder['folder_desc'];
return $this->renderString("admin-folder-edit-form.html.twig",$formVars);
}
}
$NewPlugin = new folder_properties;
\ No newline at end of file
diff --git a/src/www/ui/admin-tag.php b/src/www/ui/admin-tag.php
index 8b2cc69f..58ea71b4 100644
--- a/src/www/ui/admin-tag.php
+++ b/src/www/ui/admin-tag.php
@@ -1,163 +1,161 @@
Name = "admin_tag";
$this->Title = TITLE_admin_tag;
$this->MenuList = "Admin::Tag::Create Tag";
$this->Version = "1.3";
$this->DBaccess = PLUGIN_DB_ADMIN;
parent::__construct();
}
/**
* \brief Create Tag without tagging anything
*
* \return null for success or error text
*/
function CreateTag()
{
global $PG_CONN;
$tag_name = GetParm('tag_name', PARM_TEXT);
$tag_desc = GetParm('tag_desc', PARM_TEXT);
if (empty($tag_name))
{
$text = _("TagName must be specified. Tag Not created.");
return ($text);
}
- if(!preg_match('/^[A-Za-z0-9_~\-!@#\$%\^&\*\(\)]+$/i', $tag_name)){
- $text = _("A Tag is only allowed to contain characters from ".htmlentities("A-Za-z0-9_~-!@#$%^&*()").". Tag Not created.");
+ if(!preg_match('/^[A-Za-z0-9_~\-!@#\$%\^\*\.\(\)]+$/i', $tag_name)){
+ $text = _("A Tag is only allowed to contain characters from ".htmlentities("A-Za-z0-9_~-!@#$%^*.()").". Tag Not created.");
return ($text);
}
/* See if the tag already exists */
$sql = "SELECT * FROM tag WHERE tag = '".pg_escape_string($tag_name)."'";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
if (pg_num_rows($result) < 1)
{
pg_free_result($result);
- $Val = str_replace("'", "''", $tag_name);
- $Val1 = str_replace("'", "''", $tag_desc);
- $sql = "INSERT INTO tag (tag,tag_desc) VALUES ('".pg_escape_string($Val)."', '".pg_escape_string($Val1)."');";
+ $sql = "INSERT INTO tag (tag,tag_desc) VALUES ('".pg_escape_string($tag_name)."', '".pg_escape_string($tag_desc)."');";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
}
pg_free_result($result);
/* Make sure it was added */
$sql = "SELECT * FROM tag WHERE tag = '".pg_escape_string($tag_name)."' LIMIT 1;";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
if (pg_num_rows($result) < 1)
{
pg_free_result($result);
$text = _("Failed to create tag.");
return ($text);
}
pg_free_result($result);
return (NULL);
}
/**
* \brief Show all tags
*/
function ShowExistTags()
{
global $PG_CONN;
$VE = _("Current Tags:
\n");
$sql = "SELECT tag_pk, tag, tag_desc FROM tag ORDER BY tag_pk desc;";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
if (pg_num_rows($result) > 0)
{
$VE .= "\n";
$text1 = _("Tag pk");
$text2 = _("Tag");
$text3 = _("Tag Description");
$VE .= "$text1 | $text2 | $text3 |
\n";
while ($row = pg_fetch_assoc($result))
{
$VE .= "" . $row['tag_pk'] . " | " . htmlspecialchars($row['tag']) . " | " . htmlspecialchars($row['tag_desc']) . " | ";
}
$VE .= "
\n";
}
pg_free_result($result);
return $VE;
}
/**
* \brief Display the create tag page.
*/
function ShowCreateTagPage()
{
$VC = "";
$VC .= _("
Create Tag:
\n");
$VC.= "\n";
return $VC;
}
public function Output()
{
$V="";
$action = GetParm('action', PARM_TEXT);
if ($action == 'add')
{
$rc = $this->CreateTag();
if (!empty($rc))
{
$text = _("Create Tag Failed");
$V .= displayMessage("$text: $rc");
} else {
$text = _("Create Tag Successful!");
$V .= displayMessage($text);
}
}
$V .= $this->ShowCreateTagPage();
$V .= $this->ShowExistTags();
return $V;
}
}
$NewPlugin = new admin_tag;
$NewPlugin->Initialize();
diff --git a/src/www/ui/index.php b/src/www/ui/index.php
index 842bd1d9..0c0b30c1 100644
--- a/src/www/ui/index.php
+++ b/src/www/ui/index.php
@@ -1,75 +1,78 @@
get("log.timing");
$timingLogger->logWithStartTime("bootstrap", $startTime);
/* Initialize global system configuration variables $SysConfig[] */
$timingLogger->tic();
ConfigInit($SYSCONFDIR, $SysConf);
$timingLogger->toc("setup init");
$timingLogger->tic();
plugin_load();
plugin_preinstall();
plugin_postinstall();
$timingLogger->toc("setup plugins");
$plugin = plugin_find(GetParm("mod", PARM_STRING) ?: HomePage::NAME);
if ($plugin)
{
$timingLogger->tic();
$plugin->execute();
$timingLogger->toc("plugin execution");
} else
{
$linkUri = Traceback_uri() . "?mod=auth";
$errorText = _("Module unavailable or your login session timed out.");
print "$errorText ";
$linkText = _("Click here to continue.");
print "$linkText";
}
plugin_unload();
$container->get("db.manager")->flushStats();
return 0;
\ No newline at end of file
diff --git a/src/www/ui/showjobs.php b/src/www/ui/showjobs.php
index 5e900135..c80a913a 100644
--- a/src/www/ui/showjobs.php
+++ b/src/www/ui/showjobs.php
@@ -1,231 +1,226 @@
Name = "showjobs";
$this->Title = TITLE_showjobs;
$this->MenuOrder = 5;
$this->Dependency = array("browse");
$this->DBaccess = PLUGIN_DB_WRITE;
global $container;
$this->showJobsDao = $container->get('dao.show_jobs');
$this->uploadDao = $container->get('dao.upload');
parent::__construct();
}
function RegisterMenus()
{
menu_insert("Main::Jobs::My Recent Jobs",$this->MenuOrder -1,$this->Name, $this->MenuTarget);
if ($_SESSION[Auth::USER_LEVEL] != PLUGIN_DB_ADMIN) return;
if (GetParm("mod", PARM_STRING) == $this->Name){
/* Set micro menu to select either all users or this user */
$allusers = GetParm("allusers",PARM_INTEGER);
if ($allusers == 0){
$text = _("Show uploads from all users");
$URI = $this->Name . Traceback_parm_keep(array( "page" )) . "&allusers=1";
}else{
$text = _("Show only your own uploads");
$URI = $this->Name . Traceback_parm_keep(array( "page")) . "&allusers=0";
}
menu_insert("showjobs::$text", 1, $URI, $text);
}
} // RegisterMenus()
/**
* @brief Returns geeky scan details about the jobqueue item
* @param $job_pk
* @return Return job and jobqueue record data in an html table.
**/
function showJobDB($job_pk)
{
global $container;
/** @var DbManager */
$dbManager = $container->get('db.manager');
$statementName = __METHOD__."ShowJobDBforjob";
$dbManager->prepare($statementName,
"SELECT *, jq_endtime-jq_starttime as elapsed FROM jobqueue LEFT JOIN job ON job.job_pk = jobqueue.jq_job_fk WHERE jobqueue.jq_pk = $1");
$result = $dbManager->execute($statementName, array($job_pk));
$row = $dbManager->fetchArray($result);
$dbManager->freeResult($result);
if (!empty($row["job_upload_fk"])){
/* get the upload filename */
$statementName = __METHOD__."upload_filenameforShowJobDB";
$dbManager->prepare($statementName, "select upload_filename from upload where upload_pk =$1");
$uploadresult = $dbManager->execute($statementName, array($row['job_upload_fk']));
$uploadRow = $dbManager->fetchArray($uploadresult);
if (empty($uploadRow)){
/* upload has been deleted so try to get the job name from the original upload job record */
$jobName = $this->showJobsDao->getJobName($row["job_upload_fk"]);
$upload_filename = "Deleted " . $jobName;
}else{
$upload_filename = $uploadRow['upload_filename'];
}
$dbManager->freeResult($uploadresult);
if (empty($row['jq_pk'])){
return _("Job history record is no longer available");
}
$uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($row['job_upload_fk']);
/* Find the uploadtree_pk for this upload so that it can be used in the browse link */
$statementName = __METHOD__."uploadtreeRec";
$uploadtreeRec = $dbManager->getSingleRow(
"select * from $uploadtree_tablename where parent is NULL and upload_fk=$1",
array($row['job_upload_fk']),
$statementName);
$uploadtree_pk = $uploadtreeRec['uploadtree_pk'];
}
/* upload file name link to browse */
if (!empty($row['job_upload_fk'])){
$uploadTreeName = "" . $upload_filename . "";
return $uploadTreeName;
}
} // showJobDB()
public function Output()
{
$page = "";
$uploadPk = GetParm('upload',PARM_INTEGER);
if (empty($uploadPk)){
$uploadPk = -1;
}
elseif($uploadPk>0){
if (!$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())){
$text = _("Permission Denied");
return "$text
";
}
}
$this->vars['uploadId']= $uploadPk;
- // micro menus
- menu_to_1html(menu_find($this->Name, $MenuDepth),0);
/* Process any actions */
if ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_WRITE){
$jq_pk = GetParm("jobid",PARM_INTEGER);
$action = GetParm("action",PARM_STRING);
$uploadPk = GetParm("upload",PARM_INTEGER);
if (!empty($uploadPk) && !$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())){
$text = _("Permission Denied");
return "$text
";
}
$page = GetParm('page',PARM_INTEGER) ?: 0;
$thisURL = Traceback_uri() . "?mod=" . $this->Name . "&upload=$uploadPk";
switch($action)
{
case 'pause':
if (empty($jq_pk)) break;
$command = "pause $jq_pk";
$rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info);
if ($rv == false) $this->vars['errorInfo'] = _("Unable to pause job.") . " " . $response_from_scheduler . $error_info;
echo "";
break;
case 'restart':
if (empty($jq_pk)) break;
$command = "restart $jq_pk";
$rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info);
if ($rv == false) $this->vars['errorInfo'] = _("Unable to restart job.") . " " . $response_from_scheduler . $error_info;
echo "";
break;
case 'cancel':
if (empty($jq_pk)) break;
$Msg = "\"" . _("Killed by") . " " . $_SESSION[Auth::USER_NAME] . "\"";
$command = "kill $jq_pk $Msg";
$rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info);
if ($rv == false) $this->vars['errorInfo'] = _("Unable to cancel job.") . $response_from_scheduler . $error_info;
echo "";
break;
-
- default:
- break;
}
}
$job = GetParm('job',PARM_INTEGER);
if (!empty($job)){
$this->vars['jobId'] = $job;
$this->vars['uploadName'] = $this->showJobDB($job);
}else{
$allusersval=GetParm("allusers",PARM_INTEGER);
if(!$allusersval) $allusersval = 0;
$this->vars['allusersval'] = $allusersval;
if(!$page) $page=0;
$this->vars['page'] = $page;
$this->vars['clockTime'] = $this->getTimeToRefresh();
$this->vars['allusersdiv'] = menu_to_1html(menu_find($this->Name, $MenuDepth),0);
$this->vars['injectedFoot'] = $_GET['injectedFoot'];
$this->vars['message'] = $_GET['injectedMessage'];
}
}
/**
* @brief getTimeToRefresh() get the refresh time from DB.
* @Returns time in seconds to refresh the jobs.
**/
public function getTimeToRefresh()
{
global $SysConf;
return $SysConf['SYSCONFIG']['ShowJobsAutoRefresh'];
} /* getTimeToRefresh() */
public function getTemplateName()
{
$job = GetParm('job', PARM_INTEGER);
if (empty($job)) {
return "ui-showjobs.html.twig";
}
else {
return "ui-job-show.html.twig";
}
}
}
$NewPlugin = new showjobs;
$NewPlugin->Initialize();
diff --git a/src/www/ui/template/admin-folder-create-form.html.twig b/src/www/ui/template/admin-folder-create-form.html.twig
index 0ae26e86..57b88ce5 100644
--- a/src/www/ui/template/admin-folder-create-form.html.twig
+++ b/src/www/ui/template/admin-folder-create-form.html.twig
@@ -1,29 +1,29 @@
{# Copyright 2016 Siemens AG
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
This file is offered as-is, without any warranty.
#}
diff --git a/src/www/ui/template/admin-folder-edit-form.html.twig b/src/www/ui/template/admin-folder-edit-form.html.twig
index 200a1ea6..c59970c7 100644
--- a/src/www/ui/template/admin-folder-edit-form.html.twig
+++ b/src/www/ui/template/admin-folder-edit-form.html.twig
@@ -1,27 +1,27 @@
{{ "The folder properties that can be changed are the folder name and description."|trans }}
{{ "First select the folder to edit. Then enter the new values."|trans }}
{{ "If no value is entered, then the corresponding field will not be changed."|trans }}
diff --git a/src/www/ui/ui-view-info.php b/src/www/ui/ui-view-info.php
index fd4ebfd0..f5da7d39 100644
--- a/src/www/ui/ui-view-info.php
+++ b/src/www/ui/ui-view-info.php
@@ -1,615 +1,615 @@
Name = "view_info";
$this->Title = _("View File Information");
$this->Dependency = array("browse");
$this->DBaccess = PLUGIN_DB_READ;
$this->LoginFlag = 0;
parent::__construct();
$this->uploadDao = $GLOBALS['container']->get('dao.upload');
$this->dbManager = $GLOBALS['container']->get('db.manager');
}
/**
* \brief Customize submenus.
*/
function RegisterMenus()
{
$tooltipText = _("View file information");
menu_insert("Browse-Pfile::Info",5,$this->Name,$tooltipText);
// For the Browse menu, permit switching between detail and summary.
$Parm = Traceback_parm_keep(array("upload","item","format"));
$URI = $this->Name . $Parm;
$menuPosition = 60;
$menuText = "Info";
if (GetParm("mod",PARM_STRING) == $this->Name)
{
menu_insert("View::[BREAK]", 61);
menu_insert("View::[BREAK]", 50);
menu_insert("View::{$menuText}", $menuPosition);
menu_insert("View-Meta::[BREAK]", 61);
menu_insert("View-Meta::[BREAK]", 50);
menu_insert("View-Meta::{$menuText}", $menuPosition);
menu_insert("Browse::Info",-3);
}
else
{
$tooltipText = _("View information about this file");
menu_insert("View::[BREAK]", 61);
menu_insert("View::[BREAK]", 50);
menu_insert("View::{$menuText}", $menuPosition, $URI, $tooltipText);
menu_insert("View-Meta::[BREAK]", 61);
menu_insert("View-Meta::[BREAK]", 50);
menu_insert("View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
menu_insert("Browse::Info", -3, $URI, $tooltipText);
}
} // RegisterMenus()
/**
* \brief Display the info data associated with the file.
*/
function ShowView($Upload, $Item, $ShowMenu=0)
{
$V = "";
if (empty($Upload) || empty($Item)) { return; }
$Page = GetParm("page",PARM_INTEGER);
if (empty($Page)) { $Page=0; }
/**********************************
List File Info
**********************************/
if ($Page == 0)
{
$text = _("Repository Locator");
$V .= "$text
\n";
$sql = "SELECT * FROM uploadtree
INNER JOIN pfile ON uploadtree_pk = $1
AND pfile_fk = pfile_pk
LIMIT 1;";
- $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__.md5($sql));
+ $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__."GetFileDescribingRow");
$V .= "\n";
$text = _("Attribute");
$text1 = _("Value");
$V .= "$text | $text1 |
\n";
$Bytes = $R['pfile_size'];
$BytesH = HumanSize($Bytes);
$Bytes = number_format($Bytes, 0, "", ",").' B';
if ($BytesH == $Bytes) { $BytesH = ""; }
else { $BytesH = '(' . $BytesH . ')'; }
$text = _("File Size");
$V .= "$text | $Bytes $BytesH |
\n";
$text = _("SHA1 Checksum");
$V .= "$text | " . $R['pfile_sha1'] . " |
\n";
$text = _("MD5 Checksum");
$V .= "$text | " . $R['pfile_md5'] . " |
\n";
$text = _("Repository ID");
$V .= "$text | " . $R['pfile_sha1'] . "." . $R['pfile_md5'] . "." . $R['pfile_size'] . " |
\n";
$text = _("Pfile ID");
$V .= "$text | " . $R['pfile_fk'] . " |
\n";
$V .= "
\n";
}
return($V);
} // ShowView()
/**
* \brief Show Sightings, List the directory locations where this pfile is found
*/
function ShowSightings($Upload, $Item)
{
$V = "";
if (empty($Upload) || empty($Item)) { return; }
$Page = GetParm("page",PARM_INTEGER);
if (empty($Page)) { $Page=0; }
$Max = 50;
$Offset = $Page * $Max;
/**********************************
List the directory locations where this pfile is found
**********************************/
$text = _("Sightings");
$V .= "$text
\n";
$sql = "SELECT * FROM pfile,uploadtree
WHERE pfile_pk=pfile_fk
AND pfile_pk IN
(SELECT pfile_fk FROM uploadtree WHERE uploadtree_pk = $1)
LIMIT $2 OFFSET $3";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($Item,$Max,$Offset));
+ $this->dbManager->prepare(__METHOD__."getListOfFiles",$sql);
+ $result = $this->dbManager->execute(__METHOD__,array($Item,$Max,$Offset));
$Count = pg_num_rows($result);
if (($Page > 0) || ($Count >= $Max))
{
$VM = "\n" . MenuEndlessPage($Page, ($Count >= $Max)) . "\n";
}
else { $VM = ""; }
if ($Count > 0)
{
$V .= _("This exact file appears in the following locations:\n");
$V .= $VM;
$Offset++;
$V .= Dir2FileList($result,"browse","view",$Offset);
$V .= $VM;
}
else if ($Page > 0)
{
$V .= _("End of listing.\n");
}
else
{
$V .= _("This file does not appear in any other known location.\n");
}
pg_free_result($result);
return($V);
}//ShowSightings()
/**
* \brief Display the meta data associated with the file.
*/
function ShowMetaView($Upload, $Item)
{
$V = "";
$Count = 1;
if (empty($Item) || empty($Upload))
{ return; }
/**********************************
Display meta data
**********************************/
$text = _("File Info");
$V .= "$text
\n";
$V .= "\n";
$text = _("Item");
$text1 = _("Meta Data");
$text2 = _("Value");
$V .= "$text | $text1 | $text2 |
\n";
/* display mimetype */
$sql = "SELECT * FROM uploadtree where uploadtree_pk = $1";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($Item));
+ $this->dbManager->prepare(__METHOD__."DisplayMimetype",$sql);
+ $result = $this->dbManager->execute(__METHOD__."getUploadTree",array($Item));
if (pg_num_rows($result))
{
$row = pg_fetch_assoc($result);
if (!empty($row['mimetype_pk']))
{
$V .= "" . $Count++ . " | Unpacked file type";
$V .= " | " . htmlentities($row['mimetype_name']) . " |
\n";
}
}
else
{
// bad uploadtree_pk
pg_free_result($result);
$text = _("File does not exist in database");
return $text;
}
$this->dbManager->freeResult($result);
/* get mimetype */
if (!empty($row['pfile_fk']))
{
$sql = "select mimetype_name from pfile, mimetype where pfile_pk = $1 and pfile_mimetypefk=mimetype_pk";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($row[pfile_fk]));
+ $this->dbManager->prepare(__METHOD__."GetMimetype",$sql);
+ $result = $this->dbManager->execute(__METHOD__."getMimetype",array($row[pfile_fk]));
if (pg_num_rows($result))
{
$pmRow = pg_fetch_assoc($result);
$V .= "" . $Count++ . " | Unpacked file type";
$V .= " | " . htmlentities($pmRow['mimetype_name']) . " |
\n";
}
$this->dbManager->freeResult($result);
}
/* display upload origin */
$sql = "select * from upload where upload_pk=$1";
- $row = $this->dbManager->getSingleRow($sql,array($row[upload_fk]),__METHOD__.md5($sql));
+ $row = $this->dbManager->getSingleRow($sql,array($row[upload_fk]),__METHOD__."getUploadOrigin");
if ($row)
{
/* upload source */
if ($row['upload_mode'] & 1 << 2) $text = _("Added by URL: ");
else if ($row['upload_mode'] & 1 << 3) $text = _("Added by file upload: ");
else if ($row['upload_mode'] & 1 << 4) $text = _("Added from filesystem: ");
$V .= "" . $Count++ . " | $text | ";
$V .= "" . htmlentities($row['upload_origin']) . " |
\n";
/* upload time */
$text = _("Added to repo");
$V .= "" . $Count++ . " | $text | ";
$ts = $row['upload_ts'];
$V .= "" . substr($ts, 0, strrpos($ts, '.')) . " |
\n";
}
/* display where it was uploaded from */
/* display upload owner*/
$sql = "SELECT user_name from users, upload where user_pk = user_fk and upload_pk = $1";
- $row = $this->dbManager->getSingleRow($sql,array($Upload),__METHOD__.md5($sql));
+ $row = $this->dbManager->getSingleRow($sql,array($Upload),__METHOD__."getUploadOwner");
$text = _("Added by");
$V .= "" . $Count++ . " | $text | ";
$V .= "" . $row['user_name'] . " |
\n";
$V .= "
\n";
return($V);
} // ShowMetaView()
/**
* \brief Display the package info associated with
* the rpm/debian package.
*/
function ShowPackageInfo($Upload, $Item, $ShowMenu=0)
{
$V = "";
$Require = "";
$MIMETYPE = "";
$Count = 0;
$rpm_info = array("Package"=>"pkg_name",
"Alias"=>"pkg_alias",
"Architecture"=>"pkg_arch",
"Version"=>"version",
"License"=>"license",
"Group"=>"pkg_group",
"Packager"=>"packager",
"Release"=>"release",
"BuildDate"=>"build_date",
"Vendor"=>"vendor",
"URL"=>"url",
"Summary"=>"summary",
"Description"=>"description",
"Source"=>"source_rpm");
$deb_binary_info = array("Package"=>"pkg_name",
"Architecture"=>"pkg_arch",
"Version"=>"version",
"Section"=>"section",
"Priority"=>"priority",
"Installed Size"=>"installed_size",
"Maintainer"=>"maintainer",
"Homepage"=>"homepage",
"Source"=>"source",
"Summary"=>"summary",
"Description"=>"description");
$deb_source_info = array("Format"=>"format",
"Source"=>"source",
"Binary"=>"pkg_name",
"Architecture"=>"pkg_arch",
"Version"=>"version",
"Maintainer"=>"maintainer",
"Uploaders"=>"uploaders",
"Standards-Version"=>"standards_version");
if (empty($Item) || empty($Upload)) { return; }
/**********************************
Check if pkgagent disabled
***********************************/
$sql = "SELECT agent_enabled FROM agent WHERE agent_name ='pkgagent' order by agent_ts LIMIT 1;";
- $row = $this->dbManager->getSingleRow($sql,array(),__METHOD__.md5($sql));
+ $row = $this->dbManager->getSingleRow($sql,array(),__METHOD__."checkPkgagentDisabled");
if (isset($row) && ($row['agent_enabled']== 'f')){return;}
/**********************************
Display package info
**********************************/
$text = _("Package Info");
$V .= "$text
\n";
/* If pkgagent_ars table didn't exists, don't show the result. */
$sql = "SELECT typlen FROM pg_type where typname='pkgagent_ars' limit 1;";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array());
+ $this->dbManager->prepare(__METHOD__."displayPackageInfo",$sql);
+ $result = $this->dbManager->execute(__METHOD__."displayPackageInfo",array());
$numrows = pg_num_rows($result);
$this->dbManager->freeResult($result);
if ($numrows <= 0)
{
$V .= _("No data available. Use Jobs > Agents to schedule a pkgagent scan.");
return($V);
}
/* If pkgagent_ars table didn't have record for this upload, don't show the result. */
$agent_status = AgentARSList('pkgagent_ars', $Upload);
if (empty($agent_status))
{
/** schedule pkgagent */
$V .= ActiveHTTPscript("Schedule");
$V .= "\n";
$V .= "\n";
return($V);
}
$sql = "SELECT mimetype_name
FROM uploadtree
INNER JOIN pfile ON uploadtree_pk = $1
AND pfile_fk = pfile_pk
INNER JOIN mimetype ON pfile_mimetypefk = mimetype_pk;";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($Item));
+ $this->dbManager->prepare(__METHOD__."getMimetypeName",$sql);
+ $result = $this->dbManager->execute(__METHOD__."getMimetypeName",array($Item));
while ($row = pg_fetch_assoc($result))
{
if (!empty($row['mimetype_name']))
{
$MIMETYPE = $row['mimetype_name'];
}
}
$this->dbManager->freeResult($result);
/** RPM Package Info **/
if ($MIMETYPE == "application/x-rpm")
{
$sql = "SELECT *
FROM pkg_rpm
INNER JOIN uploadtree ON uploadtree_pk = $1
AND uploadtree.pfile_fk = pkg_rpm.pfile_fk;";
- $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__.md5($sql));
+ $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__."getRPMPackageInfo");
if((!empty($R['source_rpm']))and(trim($R['source_rpm']) != "(none)"))
{
$V .= _("RPM Binary Package");
}
else
{
$V .= _("RPM Source Package");
}
$Count=1;
$V .= "\n";
$text = _("Item");
$text1 = _("Type");
$text2 = _("Value");
$V .= "$text | $text1 | $text2 |
\n";
if (!empty($R['pkg_pk']))
{
$Require = $R['pkg_pk'];
foreach ($rpm_info as $key=>$value)
{
$text = _($key);
$V .= "$Count | $text";
$V .= " | " . htmlentities($R["$value"]) . " |
\n";
$Count++;
}
$sql = "SELECT * FROM pkg_rpm_req WHERE pkg_fk = $1;";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($Require));
+ $this->dbManager->prepare(__METHOD__."getPkg_rpm_req",$sql);
+ $result = $this->dbManager->execute(__METHOD__."getPkg_rpm_req",array($Require));
while ($R = pg_fetch_assoc($result) and !empty($R['req_pk']))
{
$text = _("Requires");
$V .= "$Count | $text";
$Val = htmlentities($R['req_value']);
$Val = preg_replace("@((http|https|ftp)://[^{}<>&[:space:]]*)@i","\$1",$Val);
$V .= " | $Val |
\n";
$Count++;
}
$this->dbManager->freeResult($result);
}
$V .= "
\n";
}
else if ($MIMETYPE == "application/x-debian-package")
{
$V .= _("Debian Binary Package\n");
$sql = "SELECT *
FROM pkg_deb
INNER JOIN uploadtree ON uploadtree_pk = $1
AND uploadtree.pfile_fk = pkg_deb.pfile_fk;";
- $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__.md5($sql));
+ $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__."debianBinaryPackageInfo");
$Count=1;
$V .= "\n";
$text = _("Item");
$text1 = _("Type");
$text2 = _("Value");
$V .= "$text | $text1 | $text2 |
\n";
if ($R)
{
$Require = $R['pkg_pk'];
foreach ($deb_binary_info as $key=>$value)
{
$text = _($key);
$V .= "$Count | $text";
$V .= " | " . htmlentities($R["$value"]) . " |
\n";
$Count++;
}
pg_free_result($result);
$sql = "SELECT * FROM pkg_deb_req WHERE pkg_fk = $1;";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($Require));
+ $this->dbManager->prepare(__METHOD__."getPkg_rpm_req",$sql);
+ $result = $this->dbManager->execute(__METHOD__."getPkg_rpm_req",array($Require));
while ($R = pg_fetch_assoc($result) and !empty($R['req_pk']))
{
$text = _("Depends");
$V .= "$Count | $text";
$Val = htmlentities($R['req_value']);
$Val = preg_replace("@((http|https|ftp)://[^{}<>&[:space:]]*)@i","\$1",$Val);
$V .= " | $Val |
\n";
$Count++;
}
$this->dbManager->freeResult($result);
}
$V .= "
\n";
}
else if ($MIMETYPE == "application/x-debian-source")
{
$V .= _("Debian Source Package\n");
$sql = "SELECT *
FROM pkg_deb
INNER JOIN uploadtree ON uploadtree_pk = $1
AND uploadtree.pfile_fk = pkg_deb.pfile_fk;";
- $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__.md5($sql));
+ $R = $this->dbManager->getSingleRow($sql,array($Item),__METHOD__."debianSourcePakcageInfo");
$Count=1;
$V .= "\n";
$text = _("Item");
$text1 = _("Type");
$text2 = _("Value");
$V .= "$text | $text1 | $text2 |
\n";
if ($R)
{
$Require = $R['pkg_pk'];
foreach ($deb_source_info as $key=>$value)
{
$text = _($key);
$V .= "$Count | $text";
$V .= " | " . htmlentities($R["$value"]) . " |
\n";
$Count++;
}
pg_free_result($result);
$sql = "SELECT * FROM pkg_deb_req WHERE pkg_fk = $1;";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($Require));
+ $this->dbManager->prepare(__METHOD__."getPkg_rpm_req",$sql);
+ $result = $this->dbManager->execute(__METHOD__."getPkg_rpm_req",array($Require));
while ($R = pg_fetch_assoc($result) and !empty($R['req_pk']))
{
$text = _("Build-Depends");
$V .= "$Count | $text";
$Val = htmlentities($R['req_value']);
$Val = preg_replace("@((http|https|ftp)://[^{}<>&[:space:]]*)@i","\$1",$Val);
$V .= " | $Val |
\n";
$Count++;
}
$this->dbManager->freeResult($result);
}
$V .= "
\n";
}
else
{
/* Not a package */
return "";
}
return($V);
} // ShowPackageInfo()
/**
* \brief Display the tag info data associated with the file.
*/
function ShowTagInfo($Upload, $Item)
{
$VT = "";
$text = _("Tag Info");
$VT .= "$text
\n";
$groupId = Auth::getGroupId();
$row = $this->uploadDao->getUploadEntry($Item);
if (empty($row))
{
$text = _("Invalid URL, nonexistant item");
return "$text $Item
";
}
$lft = $row["lft"];
$rgt = $row["rgt"];
$upload_pk = $row["upload_fk"];
if (empty($lft))
{
$text = _("Upload data is unavailable. It needs to be unpacked.");
return "$text uploadtree_pk: $Item
";
}
$sql = "SELECT * FROM uploadtree INNER JOIN (SELECT * FROM tag_file,tag WHERE tag_pk = tag_fk) T
ON uploadtree.pfile_fk = T.pfile_fk WHERE uploadtree.upload_fk = $1
AND uploadtree.lft >= $2 AND uploadtree.rgt <= $3 UNION SELECT * FROM uploadtree INNER JOIN
(SELECT * FROM tag_uploadtree,tag WHERE tag_pk = tag_fk) T ON uploadtree.uploadtree_pk = T.uploadtree_fk
WHERE uploadtree.upload_fk = $1 AND uploadtree.lft >= $2 AND uploadtree.rgt <= $3 ORDER BY ufile_name";
- $this->dbManager->prepare(__METHOD__.md5($sql),$sql);
- $result = $this->dbManager->execute(__METHOD__.md5($sql),array($upload_pk, $lft,$rgt));
+ $this->dbManager->prepare(__METHOD__,$sql);
+ $result = $this->dbManager->execute(__METHOD__,array($upload_pk, $lft,$rgt));
if (pg_num_rows($result) > 0)
{
$VT .= "\n";
$text = _("FileName");
$text2 = _("Tag");
$VT .= "$text | $text2 | |
\n";
while ($row = pg_fetch_assoc($result))
{
$VT .= "" . $row['ufile_name'] . " | " . $row['tag'] . " | ";
if ($this->uploadDao->isAccessible($upload_pk, $groupId))
{
$VT .= "View |
\n";
}else{
$VT .= " | \n";
}
}
$VT .= "
\n";
}
$this->dbManager->freeResult($result);
return $VT;
}
public function Output()
{
$uploadId = GetParm("upload",PARM_INTEGER);
if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) return;
$itemId = GetParm("item",PARM_INTEGER);
$this->vars['micromenu'] = Dir2Browse("browse", $itemId, NULL, $showBox=0, "View-Meta");
$V="";
$V .= $this->ShowTagInfo($uploadId, $itemId);
$V .= $this->ShowPackageinfo($uploadId, $itemId, 1);
$V .= $this->ShowMetaView($uploadId, $itemId);
$V .= $this->ShowSightings($uploadId, $itemId);
$V .= $this->ShowView($uploadId, $itemId);
return $V;
}
}
$NewPlugin = new ui_view_info;
$NewPlugin->Initialize();